#include "Agent.h"
#include "AgentState.h"

Agent::Agent(tank_t* tank)
{
	this->tank = tank;
	currentState = 0;
}


Agent::~Agent(void)
{
}

Command Agent::GetCommand(){
	if (currentState)
		return currentState->GetCommand(this);

	return Command(this->tank->index, 0, 0, false);
}

tank_t* Agent::getTank(){
	return tank;
}

void Agent::setState(AgentState* newState) {
	if (currentState) {
		currentState->exit(this);
		delete currentState;
	}

	currentState = newState;

	if (currentState)
		currentState->enter(this);
}